from .time import Time
from .socket import Socket
from .random import Random
from .list import List
from .ai import Ai
import app as robot_script

class Common:

    def __init__(self, framework):
        self.framework = framework
        self.func = dir(robot_script)
        self.time = Time(self)
        self.socket = Socket(self)
        self.random = Random(self)
        self.list = List(self)
        self.ai = Ai(self)

    def message_callback(self, message):
        func_str = "ai_event_{}".format(message["data"]["content"])
        if func_str in self.func:
            getattr(robot_script, func_str)(self.framework)
